package com.vgooo.client.tool.branch;

import android.os.Bundle;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebSettings.TextSize;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.umeng.analytics.MobclickAgent;
import com.vgooo.client.R;
import com.vgooo.client.VGActivity;
import com.vgooo.util.DebugTools;

public class BranchMapActivity extends VGActivity {

	private final static String className = "BranchMapActivity" ;
	
	
	private WebView webView;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.tool_branch_map);
		initView();
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		// 友盟统计功能，打开页面
		MobclickAgent.onResume(this);
		super.onResume();
		getData();
	}
	
	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		// 友盟统计功能，页面关闭
		MobclickAgent.onPause(this);
		super.onPause();
	}

	@Override
	public void doClick(View v) {
		// TODO Auto-generated method stub

	}

	@Override
	public void initView() {
		// TODO Auto-generated method stub
		webView = (WebView) findViewById(R.id.tool_branch_map);

		// 设置支持JavaScript
		WebSettings setting = webView.getSettings();
		setting.setDefaultTextEncodingName("UTF-8");// 设置编码
		setting.setPluginsEnabled(true);// 是否支持插件
		setting.setJavaScriptEnabled(true);// 设置是否支持javaScript
		setting.setTextSize(TextSize.NORMAL);// 设置为小字体
		// setting.setUseWideViewPort(true);//将图片调到适合webView的大小
		setting.setSupportZoom(true);// 支持缩放
		setting.setDefaultZoom(WebSettings.ZoomDensity.FAR);// 设置默认缩放方式的尺寸是far
		setting.setBuiltInZoomControls(true);// 设置出现缩放工具
		webView.getSettings().setJavaScriptEnabled(true);
		// 设置页面中的链接继续在当前brower中响应，而不是打开android系统的Activity
		webView.setWebViewClient(new WebViewClient() {
			@Override
			public boolean shouldOverrideUrlLoading(WebView view, String url) {
				// TODO Auto-generated method stub
				webView.loadUrl(url);
				return true;
			}

		});
	}

	@Override
	public void setupView() {
		// TODO Auto-generated method stub

	}

	@Override
	public void addListener() {
		// TODO Auto-generated method stub

	}

	@Override
	public void flashView() {
		// TODO Auto-generated method stub

	}

	@Override
	public void getData() {
		// TODO Auto-generated method stub
		String link = getIntent().getStringExtra("link");
		System.out.println(link);
		DebugTools.log(className, "link = " + link ) ;
		if (link != null && !"".equals(link))
			webView.loadUrl(link);
	}

}
